﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class account_account : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        var p = Page.Page;
        string pageUrl = p.ToString();
        string pageFileName = pageUrl.Substring(pageUrl.LastIndexOf('_', pageUrl.Length - 6) + 1);
        pageFileName = pageFileName.Replace('_', '.');

        FindCurrentTab(tabs, pageFileName);
    }

    bool FindCurrentTab(Control control, string pageName)
    {
        HyperLink link = control as HyperLink;

        if (link != null && link.NavigateUrl.EndsWith(pageName, StringComparison.OrdinalIgnoreCase))
        {
            link.CssClass = "currentTab";
            return true;
        }

        if (control.HasControls())
        {
            for (int i = 0; i < control.Controls.Count; i++)
            {
                if (FindCurrentTab(control.Controls[i], pageName))
                    return true;
            }
            return false;
        }
        else
            return false;
    }
}
